using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GameStateManagementSample.FrameWork.Sprite
{
    class Sprite
    {        
        public Texture2D[] Texture
        {
            get;
            set;
        }
        public Vector2 Position
        {
            get;
            set;
        }
        public int CurFrame
        {
            get;
            set;
        }
        public int ColFrame
        {
            get;
            set;
        }
        public int TotalFrame
        {
            get;
            set;
        }
        public Vector2 Size
        {
            get;
            set;
        }
        public float Depth
        {
            get;
            set;
        }
        public Vector2 Scale
        {
            get;
            set;
        }
        public float Rotation
        {
            get;
            set;
        }
        public SpriteEffects Effect
        {
            get;
            set;
        }
        public Color Color
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="_Sprite"></param>
        /// 
        public Sprite()
        {

        }
        public Sprite(Sprite _Sprite)
        {
            Texture = _Sprite.Texture;
            Size = _Sprite.Size;
            ColFrame = _Sprite.ColFrame;
            Color = _Sprite.Color;
            CurFrame = _Sprite.CurFrame;
            Depth = _Sprite.Depth;
            Scale = _Sprite.Scale;
            Rotation = _Sprite.Rotation;
            Effect = _Sprite.Effect;
        }
        public Sprite(Game _Game, string filename, int _Width, int _Hieght, int _Col, Color _Color)
        {
            Texture = new Texture2D[1];
            Texture[0] = _Game.Content.Load<Texture2D>(filename);
            Size = new Vector2(_Width, _Hieght);
            ColFrame = _Col;
            TotalFrame = 1;
            Color = _Color;
            CurFrame = 0;
            Depth = 0.0f;
            Scale = new Vector2(1.0f, 1.0f);
            Rotation = 0.0f;
            Effect = SpriteEffects.None;
        }
        virtual public void Draw(SpriteBatch _SpiteBatch)
        {
            _SpiteBatch.Draw(Texture[0], new Vector2(Position.X + (Size.X) / 2, Position.Y + (Size.Y) / 2), new Rectangle((int)((CurFrame % ColFrame) * Size.X), (int)((CurFrame / ColFrame) * Size.Y), (int)Size.X, (int)Size.Y),
                Color, Rotation, new Vector2((Size.X) / 2, (Size.Y) / 2), Scale, Effect, Depth);
        }
        virtual public void Draw(SpriteBatch _SpriteBatch, int _X, int _Y, int _KeyFrame)
        {
            _SpriteBatch.Draw(Texture[0], new Vector2(_X + Size.X / 2, _Y + Size.Y / 2), new Rectangle((int)((CurFrame % ColFrame) * Size.X), (int)((CurFrame / ColFrame) * Size.Y), (int)Size.X, (int)Size.Y),
                Color, Rotation, new Vector2((Size.X) / 2, (Size.Y) / 2), Scale, Effect, Depth);
        }
        virtual public void Draw(SpriteBatch _SpriteBatch, int _X, int _Y, int _KeyFrame,
            float _Depth, Color _Color, float _Rotation, SpriteEffects _Flip, float _ScaleX, float _ScaleY)
        {
            _SpriteBatch.Draw(Texture[0], new Vector2(_X + Size.X / 2, _Y + Size.Y / 2), new Rectangle((int)((CurFrame % ColFrame) * Size.X), (int)((CurFrame / ColFrame) * Size.Y), (int)Size.X, (int)Size.Y),
                _Color, _Rotation, new Vector2((Size.X) / 2, (Size.Y) / 2), new Vector2(_ScaleX, _ScaleY), _Flip, _Depth);
        }
    }
    
}
